<!--
 * @Descripttion:
 * @version: 1.0
 * @Author: Sam
 * @Date: 2021-07-05 10:16:07
 * @LastEditors: Sam
 * @LastEditTime: 2021-12-06 14:47:45
-->
<script src="{$resource_url}layuiadmin/layui/layui.js"></script>
<!-- <script src="http://local.vrupup.com/sanguo/shaomin/frame/public/static/layui/layui.js"></script> -->
<script src="{$resource_url}/admin/js/common2.js?v=1.0"></script>
<script src="{$resource_url}/admin/js/aliyun-oss-sdk-4.4.4.min.js"></script>
<script src="{$resource_url}/admin/js/plupload.full.min.js"></script>
<script src="{$resource_url}/admin/js/videoUpload.js?v=1.0"></script>
<script src="{$resource_url}admin/js/vue.min.js"></script>
<script src="{$resource_url}admin/js/axios.min.js"></script>
<script>
    layui.config({
        base: '{$resource_url}layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['layer', 'form'], function() {
        var $       = layui.$;
        var form    = layui.form;
        var layer   = layui.layer;
        //-------解决操作栏按钮过多时会自动隐藏,点击弹出隐藏按钮后,按钮本身绑定得监听事件失效 start----------
        $(document).off('mousedown','.layui-table-grid-down').
        on('mousedown','.layui-table-grid-down',function (event) {
            table._tableTrCurrr = $(this).closest('td');
        });
    $(document).off('click','.layui-table-tips-main [lay-event]').
        on('click','.layui-table-tips-main [lay-event]',function (event) {
            var elem = $(this);
            var tableTrCurrr =  table._tableTrCurrr;
            if(!tableTrCurrr){
                return;
            }
            var layerIndex = elem.closest('.layui-table-tips').attr('times');
            console.log(layerIndex);
            layer.close(layerIndex);
            table._tableTrCurrr.find('[lay-event="' + elem.attr('lay-event') + '"]').children("i").first().click();
    });
//-------解决操作栏按钮过多时会自动隐藏,点击弹出隐藏按钮后,按钮本身绑定得监听事件失效 end----------
        form.render();
        form.on('checkbox(checkAll)', function(data) {
            if($(data.elem).prop('checked')) {
                $('[name="ids[]"]').prop("checked", true);
                form.render();
            }else {
                $('[name="ids[]"]').prop("checked", false);
                form.render();
            }
        });
        $('.img_preview').click(function () {
            // 创建对象
            var img = new Image();
            img.src = $(this).attr('src');
            var height = img.height, width = img.width;
            while(width > 800 || height > 400) {
                height /= 2;
                width /= 2;
            }
            layer.open({
                type: 1,
                shade: false,
                title: false,
                area: [width+'px', height+ 'px'],
                content: '<img style="width: '+width+'px; height: '+height+'px;" src="'+$(this).attr('src')+'"/>'
            });
        });
    });
    // 图片预览
    function img_preview(obj) {
        var $ = layui.$;
        var layer = layui.layer;
        // 创建对象
        var img = new Image();
        img.src = $(obj).attr('src');
        var height = img.height, width = img.width;
        while(width > 800 || height > 400) {
            height /= 2;
            width /= 2;
        }
        layer.open({
            type: 1,
            shade: false,
            title: false,
            area: [width+'px', height+ 'px'],
            content: '<img style="width: '+width+'px; height: '+height+'px;" src="'+$(obj).attr('src')+'"/>'
        });
    }

    function dropdown(that) {
           var $ = layui.$;
        var oEvent = arguments.callee.caller.arguments[0] || event;
        oEvent.stopPropagation();
        var offset = $(that).offset();
        var top = offset.top - $(window).scrollTop();
        var index = $(that).parents('tr').data('index');

        if ($(document).height() < top + $(that).next('ul').height()) {
            $(that).next('ul').css({
                'padding': 10,
                'top': -($(that).parents('td').height() / 2 + $(that).height() + $(that).next('ul').height() / 2),
                'min-width': 'inherit',
                'position': 'relative'
            }).toggle();
        } else {
            $(that).next('ul').css({
                'padding': 10,
                'top': $(that).parents('td').height() / 2 + $(that).height(),
                'min-width': 'inherit',
                'position': 'relative'
            }).toggle();
        }
    }
</script>
</body>
</html>